#include<iostream>

const double * f1(const double arr[],int n);
const double * f2(const double[],int);
const double * f3(const double*, int);

int main()
{
    using namespace std;
    double ar[3] = {1112.3, 1542.5, 2227.8};
    const double* (*p1)(const double*,int) = f1;
    auto p2 = f2;
    cout << "useing pointer to functions:\n";
    cout << "Address value\n";
    cout << (*p1)(ar, 3) << " : " << *(*p1)(ar,3) << endl;  
    cout << p2(ar,3) << " : " << *p2(ar, 3) << endl;

    const double* (*pa[3])(const double*,int) = {f1, f2, f3};
    //pa an array of ponter
    auto pb = pa;
    cout << "\nUsing an array of ponters to functions:\n";
    cout << "Address value\n";
    for (int i = 0; i < 3; i++)
    {
        cout << pa[i](ar, 3) << " : " << *pa[i](ar, 3)<< endl;
    }
    cout << "\nUsing a pointer to a pointer to a function\n";
    cout << "\nAddress value\n";
    for (int i = 0; i < 3; i++)
    {
        cout << pb[i](ar, 3) << " : " << *pb[i](ar, 3) << endl;
    }

    return 0;
}

const double * f1(const double* arr,int n)
{
    return arr;
}
const double * f2(const double arr[],int n)
{   
    return arr+1;
}
const double * f3(const double arr[], int n)
{
    return arr+2;
}
